<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <div slot="header">
        <b class="u-f-16">
          <span v-if="objForm.id">编辑</span>
          <span v-else>添加</span>运费模板
        </b>
        <div class="u-right u-5mt">
          <el-button
            type="success"
            size="small"
            icon="el-icon-document-checked"
            @click="submitForm('objForm')"
            v-if="hasPerm('freightEditPost')"
          >提交保存</el-button>
          <el-button size="small" icon="el-icon-back" @click="$router.go(-1)">返回</el-button>
        </div>
      </div>
      <el-form :model="objForm" :rules="rules" ref="objForm" label-width="100px" class="u-form">
        <el-form-item label="模板名称">
          <el-input v-model="objForm.name" placeholder="请输入模板名称"></el-input>
        </el-form-item>
        <el-form-item label="基础运费">
          <el-input v-model="objForm.base_freight" :min="0" placeholder="请输入基础运费"></el-input>
        </el-form-item>
        <el-form-item label="每件递增运费">
          <el-input v-model="objForm.one_freight" :min="0" placeholder="基础每件递增运费运费"></el-input>
        </el-form-item>
        <el-form-item label="是否默认">
          <el-switch
            v-model="objForm.default"
            active-color="#13ce66"
            :active-value="1"
            inactive-color="#666"
            :inactive-value="0"
          ></el-switch>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import commonEdit from "@/mixins/common-edit";
export default {
  mixins: [commonEdit],
  data() {
    return {
      apiName: "freight",
      backRoute: "freightIndex", //成功跳转地址
      objForm: {
        id: "",
        name: "", //运费模板名称
        base_freight: 0, //基础运费
        one_freight: 0, //每件递增运费
        default: 0, //是否默认
      },
    };
  },
  methods: {},
  created() {
    if (this.$route.params.id) {
      this.objForm.id = this.$route.params.id;
    }
  },
};
</script>
